package spring.boot.demo.providerservice.controller;


import org.springframework.web.bind.annotation.*;
import spring.boot.demo.providerservice.model.TestModel;
import spring.boot.demo.providerservice.service.TestService;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

@RestController
public class HelloController {

    @Resource
    private TestService testService;


    @GetMapping("/get")
    @ResponseBody
    public String get(HttpServletResponse response, @RequestParam(value = "para") String para) {
        return para + "_get_service";
    }

    @PostMapping("/post")
    @ResponseBody
    public String post(HttpServletResponse response, @RequestParam(value = "para") String para) {
        return para + "_post_service";
    }

    @PutMapping("/put")
    @ResponseBody
    public String put(HttpServletResponse response, @RequestParam(value = "para") String para) {
        System.out.println(para + "_put_service");
        return para + "_put_service";
    }

    @DeleteMapping("/delete/{para}")
    @ResponseBody
    public String delete(HttpServletResponse response, @PathVariable(value = "para") String para) {
        System.out.println(para + "_delete_service");
        return para + "_delete_service";
    }

    @PostMapping("/getTestModel")
    @ResponseBody
    public TestModel getTestModel(HttpServletResponse response) {
        return testService.getDataTest();
    }

    @PostMapping("/getTestModelByCondition")
    @ResponseBody
    public TestModel getTestModel(HttpServletResponse response, TestModel model) {
        return testService.getDataTestByCondition(model);
    }
}
